<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'订单详情'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "137">
        <div class="analyItem" v-for="(item,index) in proportion" :key="index">
            <p class="analyItemTit tx-center" :title="item.proname">{{item.proname.substring(0,4)}}</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="cLightGray pr8">单号</span>
                    <span>{{item.orderNo}}</span>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">阶段</span>
                    <span>{{item.type}}</span>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">项目经理</span>
                    <span>{{item.pm_username}}</span>
                </p>
                <p class="col-md-4 cRed">
                    <span class="cLightGray pr8">项订完成率</span>
                    <span >{{(item.completionRate).toFixed(2)}}%</span>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">监理</span>
                    <span>{{item.supervisor_username}}</span>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">监订完成率</span>
                    <span>{{item.surRate * 100}}%</span>
                </p>
            </div>
        </div>
    </div>
    <div class="layerRtb-footer">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="cLightGray pr8">项目数量</span>
                    <span>{{proportion.length}}</span>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">项订完成率</span>
                    <span>{{completionRate.toFixed(2)}}%</span>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">监订完成率</span>
                    <span>{{surRate.toFixed(2)}}%</span>
                </p>
            </div>
        </div>
    </div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import {findCompletedProportion} from '../../Resources/Api'
export default {
    data () {
        return {
            proportion: [],
            propor: 0, // 订单数量
            completionRate: 0, // 项顶完成率
            surRate: 0
        }
    },
    created () {
        this.findCompletedProportion() // 项目经理 订单
    },
    computed: {
        ...mapGetters(['userInfo', 'leftInfo'])
    },
    methods: {
        findCompletedProportion () {
            var obj = {
                dqId: this.leftInfo.u_diqu
            }
            findCompletedProportion(obj).then(res => {
                if (res.data.statusCode === 1) {
                    this.proportion = res.data.Body.orderList
                    var completionRate = 0
                    var surRate = 0
                    this.proportion.forEach(item => {
                        completionRate += item.completionRate // 项顶 完成率
                        surRate += item.surRate * 100
                    })
                    this.surRate = surRate / this.proportion.length
                    this.completionRate = completionRate / this.proportion.length
                }
            }).catch(err => {
                console.log(err)
            })
        }

    }
}
</script>
